package com.example.factory.simple.calculator;

import java.util.Scanner;

/**
 * ^_^ 写点注释吧！
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数字：");
        String num1 = scanner.next();
        System.out.println("请输入第二个数字：");
        String num2 = scanner.next();
        System.out.println("请输入操作符：+、-、*、/");
        String op = scanner.next();

        // 工厂模式创建对象
        Operation operation = OperationFactory.createOperation(op);
        operation.setNum1(Double.parseDouble(num1));
        operation.setNum2(Double.parseDouble(num2));
        System.out.println("结果："+operation.getResult());

        // 直接使用
//        System.out.println("结果：" + Operation.getResult(Double.parseDouble(num1), Double.parseDouble(num2), Integer.parseInt(operation)));
    }

}
